#ifndef __TRANSFILE_OP_H__    
#define __TRANSFILE_OP_H__

#include <interface/data_op/transfile.h>

namespace aot{ namespace data{

class transfile_info_impl : public itransfile_info
{
public:
    virtual ~transfile_info_impl (){;}
    transfile_info_impl()
    {
        full_file_name = &full_file_name_impl;
        short_file_name = &short_file_name_impl;
        file_size = &file_size_impl;
        recv_datetime = &recv_datetime_impl;
        sender_user_id = &sender_user_id_impl;
        md5 = &md5_impl;
        id = 0;
        send_or_recv = 0;
        file_type = 0;   
        is_finish = 0;   
    }
public:
    virtual  bool clone(itransfile_info** out) 
    {
        transfile_info_impl* p = new transfile_info_impl();
        *out = p;
        return p->assign(this);
    }
    virtual  bool assign(const itransfile_info* in) 
    {
        if (NULL==in)
            return false;

        transfile_info_impl* p = (transfile_info_impl*) in;
        *this = *p;

        full_file_name = &full_file_name_impl;
        short_file_name = &short_file_name_impl;
        file_size = &file_size_impl;
        recv_datetime = &recv_datetime_impl;
        sender_user_id = &sender_user_id_impl;
        md5 = &md5_impl;  
        return true;

    }
public:
    aot::tt::str_impl full_file_name_impl;
    aot::tt::str_impl short_file_name_impl;
    aot::tt::str_impl file_size_impl;
    aot::tt::str_impl recv_datetime_impl;
    aot::tt::str_impl sender_user_id_impl;
    aot::tt::str_impl md5_impl;
};

class transfile_op_impl : public aot::data::itransfile_op
{
public:
    transfile_op_impl(void);
public:
    virtual ~transfile_op_impl(void);
public:    
    virtual bool insert(const itransfile_info* p, int& new_id);
    virtual bool del(int id); 
    virtual bool update(const itransfile_info* p);

    virtual bool read(int id, isqlite3_table** out);
    virtual bool read(int id, itransfile_info* out);
    virtual bool read(int id, itransfile_info** out);

    virtual bool get_all_info(isqlite3_table** out);
    virtual bool get_info_by_user_id(const char* user_id, isqlite3_table** out); 
    virtual bool get_info_by_user_id(const char* user_id, const char* fn, const char* md5, isqlite3_table** out); 
};

}} /* end namespace aot/data*/

#endif // __TRANSFILE_OP_H__
